package com.controller;

import com.pojo.*;
import com.service.PermissionService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Controller
public class IndexHandler {
    @Resource
    private PermissionService permissionService;
    @RequestMapping("/index")
    public String index(HttpSession session,Model model){
        User user = (User) session.getAttribute("loginUser");
        /*String rid=user.getRoleCode().substring(user.getRoleCode().indexOf("_")+1);
        System.out.println(rid);*/
        Map<Menu,List<Menu>> map = permissionService.searchNav(user.getRoleCode());
        model.addAttribute("nav",map);
        return "index";

    }
}
